#include <iostream>

using namespace std;

class Solution
{
public:
    int balancedStringSplit(string s)
    {
        int bal = 0; int cnt = 0;
        for (auto e : s)
        {
            if (e == 'R')
            {
                bal++;
            }
            else
                bal--;

            if (!bal)
            {
                cnt++;
            }
        }
        return cnt;
    }
};

int main()
{
    string s{ "RLRRLLRLRL" };

    Solution xz;
    int n = xz.balancedStringSplit(s);
    cout << n << endl;

	return 0;
}